<?php
/**
 * @filesource					HoldOrderModel.class.php
 * @desc						墓地选址模型类
 *
 * @author						zhangzhao
 * @copyright					zhangzhao@huigeyuan.com
 * @date						2011-05-12
 */

class HoldOrderModel extends CommonModel{
		protected $_validate = array(
		array('hold_place_id','require', '寄存位地址不能为空！'),
        //array('charge_person_id','require', '主办人不能为空！'),
        //array('deposit_id','require', '寄存人不能为空！'),
        array('refundment','require', '费用不能为空！'),

	);

	protected $_auto = array(
		array('status', 1),
		array('hold_start', 'time', MODEL::MODEL_INSERT, 'function'),
        array('return_time', 'time', MODEL::MODEL_UPDATE, 'function'),
		array('creater_name', 'get_current_operator_name', MODEL::MODEL_INSERT, 'function'),
	);

	//取得寄存位订购信息列表
	public function getHoldOrderList(){
		$rs = $this->db->query('select a.hold_position, b.*, c.name as deposit_name, d.name as entrepreneur from '.$this->tablePrefix.'hold_place as a,'.$this->tablePrefix.'hold_order as b,'.$this->tablePrefix.'dead as c, '.$this->tablePrefix.'general_customer as d where b.hold_place_id=a.id and '.'b.deposit_id=c.id and b.charge_person_id=d.id and b.status=1');
		return $rs;
	}
    //取得寄存位退够信息列表
	public function getHoldRequestList(){
		$rs = $this->db->query('select a.hold_position, b.*, c.name as deposit_name, d.name as entrepreneur from '.$this->tablePrefix.'hold_place as a,'.$this->tablePrefix.'hold_order as b,'.$this->tablePrefix.'dead as c, '.$this->tablePrefix.'general_customer as d where b.hold_place_id=a.id and '.'b.deposit_id=c.id and b.charge_person_id=d.id and b.status=0');
		return $rs;
	}

	//获取指定id的寄存销售记录
	public function getHoldOrderInfo($id){
		$rs = $this->db->query('select a.hold_position, b.*, c.name as deposit_name, d.name as entrepreneur from '.$this->tablePrefix.'hold_place as a,'.$this->tablePrefix.'hold_order as b,'.$this->tablePrefix.'dead as c, '.$this->tablePrefix.'general_customer as d where b.hold_place_id=a.id and '.'b.deposit_id=c.id and b.charge_person_id=d.id and b.id='.$id);
		return $rs;
	}
}
?>